#include <iostream>
#include <sys/iofunc.h>
#include <sys/dispatch.h>
#include "packet.h"

#define ATTACH_POINT "database"

using namespace std;

int main(void){
	packet_t msg;
	packet_t reply;
	 
    int fd;

    if ((fd = name_open(ATTACH_POINT, 0)) == -1) {
		cerr << "Nie mozna poalczyc sie z baza danych.";
        return -1;
    }

    msg.hdr.type = 0x00;

    /* Do whatever work you wanted with server connection */
	msg.type = PACKET_AIRPLANE_TYPE_GET;
	MsgSend(fd, &msg, sizeof(msg), &reply, sizeof(reply));
	cout<<"Otrzymalem samolot o nazwie: "<< reply.samolot_typ.nazwa<<endl;

    /* Close the connection */
    name_close(fd);
	
	
	return 0;
}